<?php

namespace app\modules\setting\models\auth;

use sookie\db\ITRecordModel;
use yii\data\ArrayDataProvider;

/**
 * 记录 "set_auth_yhzx" 的模型类.
 *
 * @property string $office_num 当前机构数.
 * @property string $seller_num 当前商家数.
 * @property string $store_num 当前店铺数.
 * @property string $selling_product 当前带货产品数.
 * @property string $video_num 当前带货视频数.
 * @property string $tiktok_num 当前带货账号数.
 */
class SetAuthYhzx extends \sookie\db\RecordModel implements ITRecordModel
{
    /**
     * {@inheritdoc}
     */
    public static function getRecordID()
    {
        return 'set_auth_yhzx';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [[["office_num","seller_num","store_num","selling_product","video_num","tiktok_num"],"safe"]];
    }

    /**
    * @param array $params
    * @return ArrayDataProvider
    * 搜索
    */
    public function search($params = []){

        $query = self::find();

        $this->load($params);

        $query->andFilterWhere(['like', 'office_num', $this->office_num]);
        $query->andFilterWhere(['like', 'seller_num', $this->seller_num]);
        $query->andFilterWhere(['like', 'store_num', $this->store_num]);
        $query->andFilterWhere(['like', 'selling_product', $this->selling_product]);
        $query->andFilterWhere(['like', 'video_num', $this->video_num]);
        $query->andFilterWhere(['like', 'tiktok_num', $this->tiktok_num]);
        
        return new ArrayDataProvider([
            'allModels' => $query->all(),
            'pagination' => [
                'pageSize' => 10,
            ],
            'sort' => [
                'attributes' => ["office_num","seller_num","store_num","selling_product","video_num","tiktok_num"],
            ],
        ]);
    }
}
